<?php

use backend\components\helper\EasyHtml;
use backend\components\widget\adminLTE\ActiveForm;;

/* @var $this yii\web\View */
/** @var $model common\models\CdnConfig */
/* @var $form yii\widgets\ActiveForm */


$this->title = '云存储';
$this->params['breadcrumbs'][] = $this->title;
?>

<div class="row">
    <div class="col-xs-12">
        <div class="box box-primary">
            <div class="box-header with-border">
                <h3 class="box-title"><?= EasyHtml::encode($this->title) ?></h3>
            </div>
            <div class="box-tools">
                    <?php $form = ActiveForm::begin(); ?>
                    <div class="box-body">
                        <p class="text-warning text-center">
                            <span><i class="fa fa-warning"></i></span>
                            默认存储地址为本地存储,若需配置云存储,状态一定要点击启用.
                        </p>
                        <?= $form->field($model, 'class')->radioList($model->classArray) ?>

                        <?php if($model->class == $model::QCloud):?>
                            <?= $form->field($model, 'appId')->textInput(['maxlength' => true]) ?>
                        <?php endif;?>

                        <?= $form->field($model, 'accessKey')->textInput(['maxlength' => true]) ?>

                        <?= $form->field($model, 'accessSecret')->textInput(['maxlength' => true]) ?>

                        <?= $form->field($model, 'bucket')->textInput(['maxlength' => true]) ?>

                        <?php if($model->class !== $model::QiNiu):?>
                            <?= $form->field($model, 'endPoint')->textInput(['maxlength' => true]) ?>
                        <?php endif;?>

                        <?= $form->field($model, 'host')->textInput(['maxlength' => true]) ?>

                        <?= $form->field($model, 'status')->radioList($model->statusTexts) ?>
                    </div>
                    <div class="box-footer">
                        <div class="pull-right">
                            <?= EasyHtml::iconSubmitButton('保存', ['class' => 'btn btn-success']) ?>
                        </div>
                    </div>
                    <?php ActiveForm::end(); ?>
            </div>
        </div>
    </div>
</div>
<script>
    $('#cdnconfig-class input').click(function () {
        layer.load(1);
        location.href = location.origin + location.pathname + '?class=' + $(this).val();
    });
</script>